<?php
/**
 * 发货单处理
 *
 * @category 
 * @package 
 * @author chenping<chenping@shopex.cn>
 * @version $Id: Z
 */
class erpapi_shop_matrix_alibaba_request_delivery extends erpapi_shop_request_delivery
{
    /**
     * 发货请求参数
     *
     * @return void
     * @author 
     **/
    protected function get_confirm_params($sdf)
    {
        //$this->__channelObj->channel['shop_id']
        
        if ($this->__channelObj->channel['tbbusiness_type'] == 'lst'){
            return $this->get_lst_confirm_params($sdf);
        }
        $param = parent::get_confirm_params($sdf);

        // 子单
        $orderEntryIds = array();
        foreach ((array) $sdf['orderinfo']['order_objects'] as $object) {
            if($object['oid']) $orderEntryIds[] = $object['oid'];
        }

        $param['memberId']        = $sdf['orderinfo']['sellermemberid'];
        $param['orderEntryIds']   = implode(',', $orderEntryIds);
        $param['tradeSourceType'] = 'cbu-trade';
        $param['remarks']         = '';
        $param['ship_date']       = date('Y-m-d H:i:s',$sdf['delivery_time']);

        return $param;
    }


    protected function get_lst_confirm_params($sdf){
        $param = parent::get_confirm_params($sdf);
        $items = array();
        foreach ($sdf['delivery_items'] as $item){
            if($item['oid']) {

                $items[] =array(

                    'oid'   =>  $item['oid'],
                    'num'   =>  $item['number'],
                    'weight'=>  "10",
                ); 
            }
                
        }
        
        $order_list = array();
        $order_list[] = array(
            'tid'   =>  $param['tid'],
            'items' =>  $items,

        );
        $param['order_list'] = json_encode($order_list);
        $param['remarks']         = '';
        $param['ship_date']       = date('Y-m-d H:i:s',$sdf['delivery_time']);
        
        return $param;
    }
}